<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>EOS.IO: contracts/eoslib/string.hpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="eos-logo.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">EOS.IO
   &#160;<span id="projectnumber">DAWN3.0.1</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_ae9b15dd87e066e1908bbd90e8f38627.html">contracts</a></li><li class="navelem"><a class="el" href="dir_3fea0bf1ce879ce73e6ecec98007efcd.html">eoslib</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">string.hpp</div>  </div>
</div><!--header-->
<div class="contents">
<a href="string_8hpp.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="preprocessor">#pragma once</span></div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="preprocessor">#include &lt;<a class="code" href="string_8h.html">eoslib/string.h</a>&gt;</span></div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="preprocessor">#include &lt;<a class="code" href="types_8hpp.html">eoslib/types.hpp</a>&gt;</span></div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="preprocessor">#include &lt;<a class="code" href="system_8h.html">eoslib/system.h</a>&gt;</span></div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="preprocessor">#include &lt;<a class="code" href="memory_8hpp.html">eoslib/memory.hpp</a>&gt;</span></div><div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="preprocessor">#include &lt;<a class="code" href="print_8hpp.html">eoslib/print.hpp</a>&gt;</span></div><div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;</div><div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="keyword">namespace </span><a class="code" href="namespaceeosio.html">eosio</a> {</div><div class="line"><a name="l00015"></a><span class="lineno"><a class="line" href="namespaceeosio.html#aae68db66d8f7985f4eb21e2d80432b28">   15</a></span>&#160;  <span class="keyword">inline</span> <span class="keywordtype">size_t</span> <a class="code" href="namespaceeosio.html#aae68db66d8f7985f4eb21e2d80432b28">cstrlen</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* cstr) {</div><div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;    <span class="keywordtype">size_t</span> len = 0;</div><div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;    <span class="keywordflow">while</span>(*cstr != <span class="charliteral">&#39;\0&#39;</span>) {</div><div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;      len++;</div><div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;      cstr++;</div><div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;    }</div><div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;    <span class="keywordflow">return</span> len;</div><div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;  }</div><div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;    </div><div class="line"><a name="l00024"></a><span class="lineno"><a class="line" href="classeosio_1_1string.html">   24</a></span>&#160;  <span class="keyword">class </span><a class="code" href="classeosio_1_1string.html">string</a> {</div><div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;     <span class="keyword">private</span>:</div><div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;       <span class="keywordtype">size_t</span>    size = 0; <span class="comment">// size of the string</span></div><div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;       <span class="keywordtype">char</span>*     data = <span class="keyword">nullptr</span>; <span class="comment">// underlying data</span></div><div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;       <span class="keywordtype">bool</span>      own_memory = <span class="keyword">false</span>; <span class="comment">// true if the object is responsible to clean the memory</span></div><div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;       <a class="code" href="group__types.html#ga06896e8c53f721507066c079052171f8">uint32_t</a>* refcount = <span class="keyword">nullptr</span>; <span class="comment">// shared reference count to the underlying data</span></div><div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;</div><div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;       <span class="comment">// Release data if no more string reference to it</span></div><div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;       <span class="keywordtype">void</span> release_data_if_needed() {</div><div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;         <span class="keywordflow">if</span> (own_memory &amp;&amp; refcount != <span class="keyword">nullptr</span>) {</div><div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;           (*refcount)--;</div><div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;           <span class="keywordflow">if</span> (*refcount == 0) {</div><div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;             <a class="code" href="group__memorycppapi.html#gadc937e4380b5ab7212b4b603ccc516c5">free</a>(data);</div><div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;           }</div><div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;         }</div><div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;       }</div><div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;</div><div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;     <span class="keyword">public</span>:</div><div class="line"><a name="l00045"></a><span class="lineno"><a class="line" href="classeosio_1_1string.html#aade33fbfd95a6faebea6da1f1486cba7">   45</a></span>&#160;       <a class="code" href="classeosio_1_1string.html#aade33fbfd95a6faebea6da1f1486cba7">string</a>() : size(0), data(nullptr), own_memory(false), refcount(nullptr) {</div><div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;       }</div><div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;</div><div class="line"><a name="l00052"></a><span class="lineno"><a class="line" href="classeosio_1_1string.html#add233f23d0dbcd7ccd96de9d1d2ed2d9">   52</a></span>&#160;       <a class="code" href="classeosio_1_1string.html#add233f23d0dbcd7ccd96de9d1d2ed2d9">string</a>(<span class="keywordtype">size_t</span> s) : size(s) {</div><div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;         <span class="keywordflow">if</span> (s == 0) {</div><div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;           data = <span class="keyword">nullptr</span>;</div><div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;           own_memory = <span class="keyword">false</span>;</div><div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;           refcount = <span class="keyword">nullptr</span>;</div><div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;         } <span class="keywordflow">else</span> {</div><div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;           data = (<span class="keywordtype">char</span> *)<a class="code" href="group__memorycppapi.html#gac4387e5dad9585f885c0c0bf8d353739">malloc</a>(s * <span class="keyword">sizeof</span>(<span class="keywordtype">char</span>));</div><div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;           own_memory = <span class="keyword">true</span>;</div><div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;           refcount = (<a class="code" href="group__types.html#ga06896e8c53f721507066c079052171f8">uint32_t</a>*)<a class="code" href="group__memorycppapi.html#gac4387e5dad9585f885c0c0bf8d353739">malloc</a>(<span class="keyword">sizeof</span>(<a class="code" href="group__types.html#ga06896e8c53f721507066c079052171f8">uint32_t</a>));</div><div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;           *refcount = 1;</div><div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;         }</div><div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;       }</div><div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;</div><div class="line"><a name="l00071"></a><span class="lineno"><a class="line" href="classeosio_1_1string.html#a8d92d1d32e18406f45f6b3ee2279606c">   71</a></span>&#160;       <a class="code" href="classeosio_1_1string.html#a8d92d1d32e18406f45f6b3ee2279606c">string</a>(<span class="keywordtype">char</span>* d, <span class="keywordtype">size_t</span> s, <span class="keywordtype">bool</span> copy) {</div><div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;         <a class="code" href="classeosio_1_1string.html#aaed931c80e0dd8542e19b211f9dc7e73">assign</a>(d, s, copy);</div><div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;       }</div><div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;</div><div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;       <span class="comment">// Copy constructor</span></div><div class="line"><a name="l00076"></a><span class="lineno"><a class="line" href="classeosio_1_1string.html#a32d0a50d44d2548303037d1eecedd077">   76</a></span>&#160;       <a class="code" href="classeosio_1_1string.html#a32d0a50d44d2548303037d1eecedd077">string</a>(<span class="keyword">const</span> <span class="keywordtype">string</span>&amp; obj) {</div><div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;         <span class="keywordflow">if</span> (<span class="keyword">this</span> != &amp;obj) {</div><div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;           data = obj.data;</div><div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;           size = obj.size;</div><div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;           own_memory = obj.own_memory;</div><div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;           refcount = obj.refcount;</div><div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;           <span class="keywordflow">if</span> (refcount != <span class="keyword">nullptr</span>) (*refcount)++;</div><div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;         }</div><div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;       }</div><div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;</div><div class="line"><a name="l00092"></a><span class="lineno"><a class="line" href="classeosio_1_1string.html#a826441441ab6ad0d7b68240714658534">   92</a></span>&#160;       <a class="code" href="classeosio_1_1string.html#a826441441ab6ad0d7b68240714658534">string</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* cstr) {</div><div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;         size = <a class="code" href="namespaceeosio.html#aae68db66d8f7985f4eb21e2d80432b28">cstrlen</a>(cstr) + 1;</div><div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;         data = (<span class="keywordtype">char</span> *)<a class="code" href="group__memorycppapi.html#gac4387e5dad9585f885c0c0bf8d353739">malloc</a>(size * <span class="keyword">sizeof</span>(<span class="keywordtype">char</span>));</div><div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;         <a class="code" href="group__memorycapi.html#ga59ed1449718a3c27f7622cb3efb845af">memcpy</a>(data, cstr, size * <span class="keyword">sizeof</span>(<span class="keywordtype">char</span>));</div><div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;         own_memory = <span class="keyword">true</span>;</div><div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;         refcount = (<a class="code" href="group__types.html#ga06896e8c53f721507066c079052171f8">uint32_t</a>*)<a class="code" href="group__memorycppapi.html#gac4387e5dad9585f885c0c0bf8d353739">malloc</a>(<span class="keyword">sizeof</span>(<a class="code" href="group__types.html#ga06896e8c53f721507066c079052171f8">uint32_t</a>));</div><div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;         *refcount = 1;</div><div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;       }</div><div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;</div><div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;       <span class="comment">// Destructor</span></div><div class="line"><a name="l00102"></a><span class="lineno"><a class="line" href="classeosio_1_1string.html#ab18d966a1121e47005d02eb54c980144">  102</a></span>&#160;       <a class="code" href="classeosio_1_1string.html#ab18d966a1121e47005d02eb54c980144">~string</a>() {</div><div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;         release_data_if_needed();</div><div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;       }</div><div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;</div><div class="line"><a name="l00106"></a><span class="lineno"><a class="line" href="classeosio_1_1string.html#a8d395e277ce5848b5a642b0d40babe9b">  106</a></span>&#160;       <span class="keywordtype">void</span> <a class="code" href="classeosio_1_1string.html#a8d395e277ce5848b5a642b0d40babe9b">resize</a>( <span class="keywordtype">size_t</span> newsize ) {</div><div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;          <span class="keywordflow">if</span>( newsize == 0 ) {</div><div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;             release_data_if_needed();</div><div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;             refcount = <span class="keyword">nullptr</span>;</div><div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;             own_memory = <span class="keyword">true</span>;</div><div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;             data = <span class="keyword">nullptr</span>;</div><div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160;             size = 0;</div><div class="line"><a name="l00113"></a><span class="lineno">  113</span>&#160;          }</div><div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;          <span class="keywordflow">else</span> <span class="keywordflow">if</span>( newsize &lt; size ) {</div><div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160;             size = newsize;</div><div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;             data[newsize] = 0;</div><div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;          }</div><div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;          <span class="keywordflow">else</span> <span class="keywordflow">if</span>( newsize &gt; size ) {</div><div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;             <span class="keywordtype">char</span>* newbuf = (<span class="keywordtype">char</span>*)<a class="code" href="group__memorycppapi.html#gac4387e5dad9585f885c0c0bf8d353739">malloc</a>( newsize );</div><div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;             <a class="code" href="group__memorycapi.html#ga59ed1449718a3c27f7622cb3efb845af">memcpy</a>( newbuf, data, size );</div><div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;             release_data_if_needed();</div><div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;             size = newsize;</div><div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;             data = newbuf;</div><div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160;             own_memory = <span class="keyword">true</span>;</div><div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;             refcount = <span class="keyword">nullptr</span>;</div><div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;          }</div><div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160;       }</div><div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160;</div><div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160;       <span class="comment">// Get size of the string (in number of bytes)</span></div><div class="line"><a name="l00130"></a><span class="lineno"><a class="line" href="classeosio_1_1string.html#a7bc7a677ca79b2b3be0091e2d035f355">  130</a></span>&#160;       <span class="keyword">const</span> <span class="keywordtype">size_t</span> <a class="code" href="classeosio_1_1string.html#a7bc7a677ca79b2b3be0091e2d035f355">get_size</a>()<span class="keyword"> const </span>{</div><div class="line"><a name="l00131"></a><span class="lineno">  131</span>&#160;         <span class="keywordflow">return</span> size;</div><div class="line"><a name="l00132"></a><span class="lineno">  132</span>&#160;       }</div><div class="line"><a name="l00133"></a><span class="lineno">  133</span>&#160;</div><div class="line"><a name="l00134"></a><span class="lineno">  134</span>&#160;       <span class="comment">// Get the underlying data of the string</span></div><div class="line"><a name="l00135"></a><span class="lineno"><a class="line" href="classeosio_1_1string.html#ab969d69b5af645bc30e2d4a602cb016e">  135</a></span>&#160;       <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="classeosio_1_1string.html#ab969d69b5af645bc30e2d4a602cb016e">get_data</a>()<span class="keyword"> const </span>{</div><div class="line"><a name="l00136"></a><span class="lineno">  136</span>&#160;         <span class="keywordflow">return</span> data;</div><div class="line"><a name="l00137"></a><span class="lineno">  137</span>&#160;       }</div><div class="line"><a name="l00138"></a><span class="lineno"><a class="line" href="classeosio_1_1string.html#aa5268fb5a75d39cb43a853f40d20925c">  138</a></span>&#160;       <span class="keywordtype">char</span>* <a class="code" href="classeosio_1_1string.html#aa5268fb5a75d39cb43a853f40d20925c">get_data</a>() {</div><div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;         <span class="keywordflow">return</span> data;</div><div class="line"><a name="l00140"></a><span class="lineno">  140</span>&#160;       }</div><div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160;</div><div class="line"><a name="l00142"></a><span class="lineno">  142</span>&#160;       <span class="comment">// Check if it owns memory</span></div><div class="line"><a name="l00143"></a><span class="lineno"><a class="line" href="classeosio_1_1string.html#a813bb1e0b11250761b63d48e3bf387b5">  143</a></span>&#160;       <span class="keyword">const</span> <span class="keywordtype">bool</span> <a class="code" href="classeosio_1_1string.html#a813bb1e0b11250761b63d48e3bf387b5">is_own_memory</a>()<span class="keyword"> const </span>{</div><div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160;         <span class="keywordflow">return</span> own_memory;</div><div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160;       }</div><div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160;</div><div class="line"><a name="l00147"></a><span class="lineno">  147</span>&#160;       <span class="comment">// Get the ref count</span></div><div class="line"><a name="l00148"></a><span class="lineno"><a class="line" href="classeosio_1_1string.html#a808f9f108bfcd8acd062483e40f46080">  148</a></span>&#160;       <span class="keyword">const</span> <a class="code" href="group__types.html#ga06896e8c53f721507066c079052171f8">uint32_t</a> <a class="code" href="classeosio_1_1string.html#a808f9f108bfcd8acd062483e40f46080">get_refcount</a>()<span class="keyword"> const </span>{</div><div class="line"><a name="l00149"></a><span class="lineno">  149</span>&#160;         <span class="keywordflow">return</span> *refcount;</div><div class="line"><a name="l00150"></a><span class="lineno">  150</span>&#160;       }</div><div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160;</div><div class="line"><a name="l00159"></a><span class="lineno"><a class="line" href="classeosio_1_1string.html#aaed931c80e0dd8542e19b211f9dc7e73">  159</a></span>&#160;       <span class="keywordtype">string</span>&amp; <a class="code" href="classeosio_1_1string.html#aaed931c80e0dd8542e19b211f9dc7e73">assign</a>(<span class="keywordtype">char</span>* d, <span class="keywordtype">size_t</span> s, <span class="keywordtype">bool</span> copy) {</div><div class="line"><a name="l00160"></a><span class="lineno">  160</span>&#160;         <span class="keywordflow">if</span> (s == 0) {</div><div class="line"><a name="l00161"></a><span class="lineno">  161</span>&#160;           <a class="code" href="classeosio_1_1string.html#aac90a49eab4c1c047f40bf7e34fb46c9">clear</a>();</div><div class="line"><a name="l00162"></a><span class="lineno">  162</span>&#160;         } <span class="keywordflow">else</span> {</div><div class="line"><a name="l00163"></a><span class="lineno">  163</span>&#160;           release_data_if_needed();</div><div class="line"><a name="l00164"></a><span class="lineno">  164</span>&#160;           <span class="keywordflow">if</span> (copy) {</div><div class="line"><a name="l00165"></a><span class="lineno">  165</span>&#160;             data = (<span class="keywordtype">char</span> *)<a class="code" href="group__memorycppapi.html#gac4387e5dad9585f885c0c0bf8d353739">malloc</a>(s * <span class="keyword">sizeof</span>(<span class="keywordtype">char</span>));</div><div class="line"><a name="l00166"></a><span class="lineno">  166</span>&#160;             <a class="code" href="group__memorycapi.html#ga59ed1449718a3c27f7622cb3efb845af">memcpy</a>(data, d, s * <span class="keyword">sizeof</span>(<span class="keywordtype">char</span>));</div><div class="line"><a name="l00167"></a><span class="lineno">  167</span>&#160;             own_memory = <span class="keyword">true</span>;</div><div class="line"><a name="l00168"></a><span class="lineno">  168</span>&#160;             refcount = (<a class="code" href="group__types.html#ga06896e8c53f721507066c079052171f8">uint32_t</a>*)<a class="code" href="group__memorycppapi.html#gac4387e5dad9585f885c0c0bf8d353739">malloc</a>(<span class="keyword">sizeof</span>(<a class="code" href="group__types.html#ga06896e8c53f721507066c079052171f8">uint32_t</a>));</div><div class="line"><a name="l00169"></a><span class="lineno">  169</span>&#160;             *refcount = 1;</div><div class="line"><a name="l00170"></a><span class="lineno">  170</span>&#160;           } <span class="keywordflow">else</span> {</div><div class="line"><a name="l00171"></a><span class="lineno">  171</span>&#160;             data = d;</div><div class="line"><a name="l00172"></a><span class="lineno">  172</span>&#160;             own_memory = <span class="keyword">false</span>;</div><div class="line"><a name="l00173"></a><span class="lineno">  173</span>&#160;             refcount = <span class="keyword">nullptr</span>;</div><div class="line"><a name="l00174"></a><span class="lineno">  174</span>&#160;           }</div><div class="line"><a name="l00175"></a><span class="lineno">  175</span>&#160;           size = s;</div><div class="line"><a name="l00176"></a><span class="lineno">  176</span>&#160;         }</div><div class="line"><a name="l00177"></a><span class="lineno">  177</span>&#160;</div><div class="line"><a name="l00178"></a><span class="lineno">  178</span>&#160;         <span class="keywordflow">return</span> *<span class="keyword">this</span>;</div><div class="line"><a name="l00179"></a><span class="lineno">  179</span>&#160;       }</div><div class="line"><a name="l00180"></a><span class="lineno">  180</span>&#160;       </div><div class="line"><a name="l00184"></a><span class="lineno"><a class="line" href="classeosio_1_1string.html#aac90a49eab4c1c047f40bf7e34fb46c9">  184</a></span>&#160;       <span class="keywordtype">void</span> <a class="code" href="classeosio_1_1string.html#aac90a49eab4c1c047f40bf7e34fb46c9">clear</a>() {</div><div class="line"><a name="l00185"></a><span class="lineno">  185</span>&#160;         release_data_if_needed();</div><div class="line"><a name="l00186"></a><span class="lineno">  186</span>&#160;         data = <span class="keyword">nullptr</span>;</div><div class="line"><a name="l00187"></a><span class="lineno">  187</span>&#160;         size = 0;</div><div class="line"><a name="l00188"></a><span class="lineno">  188</span>&#160;         own_memory = <span class="keyword">false</span>;</div><div class="line"><a name="l00189"></a><span class="lineno">  189</span>&#160;         refcount = <span class="keyword">nullptr</span>;</div><div class="line"><a name="l00190"></a><span class="lineno">  190</span>&#160;       }</div><div class="line"><a name="l00191"></a><span class="lineno">  191</span>&#160;</div><div class="line"><a name="l00199"></a><span class="lineno"><a class="line" href="classeosio_1_1string.html#acc5a44fa32bd5c717cba547333461d39">  199</a></span>&#160;       <span class="keywordtype">string</span> <a class="code" href="classeosio_1_1string.html#acc5a44fa32bd5c717cba547333461d39">substr</a>(<span class="keywordtype">size_t</span> offset, <span class="keywordtype">size_t</span> substr_size, <span class="keywordtype">bool</span> copy) {</div><div class="line"><a name="l00200"></a><span class="lineno">  200</span>&#160;         <a class="code" href="group__systemcapi.html#gae2a6ebaf48fe7c69f847ae18f109d09a">assert</a>((offset &lt; size) &amp;&amp; (offset + substr_size &lt; size), <span class="stringliteral">&quot;out of bound&quot;</span>);</div><div class="line"><a name="l00201"></a><span class="lineno">  201</span>&#160;         <span class="keywordflow">return</span> <a class="code" href="classeosio_1_1string.html#aade33fbfd95a6faebea6da1f1486cba7">string</a>(data + offset, substr_size, copy);</div><div class="line"><a name="l00202"></a><span class="lineno">  202</span>&#160;       }</div><div class="line"><a name="l00203"></a><span class="lineno">  203</span>&#160;</div><div class="line"><a name="l00204"></a><span class="lineno"><a class="line" href="classeosio_1_1string.html#a835d2c31ac35dbec36ab6d219ea87c8a">  204</a></span>&#160;       <span class="keywordtype">char</span> <a class="code" href="classeosio_1_1string.html#a835d2c31ac35dbec36ab6d219ea87c8a">operator [] </a>(<span class="keyword">const</span> <span class="keywordtype">size_t</span> index) {</div><div class="line"><a name="l00205"></a><span class="lineno">  205</span>&#160;         <a class="code" href="group__systemcapi.html#gae2a6ebaf48fe7c69f847ae18f109d09a">assert</a>(index &lt; size, <span class="stringliteral">&quot;index out of bound&quot;</span>);</div><div class="line"><a name="l00206"></a><span class="lineno">  206</span>&#160;         <span class="keywordflow">return</span> *(data + index);</div><div class="line"><a name="l00207"></a><span class="lineno">  207</span>&#160;       }</div><div class="line"><a name="l00208"></a><span class="lineno">  208</span>&#160;</div><div class="line"><a name="l00209"></a><span class="lineno">  209</span>&#160;       <span class="comment">// Assignment operator</span></div><div class="line"><a name="l00210"></a><span class="lineno"><a class="line" href="classeosio_1_1string.html#ade94c8786b431478f43855f55e03506b">  210</a></span>&#160;       <span class="keywordtype">string</span>&amp; <a class="code" href="classeosio_1_1string.html#ade94c8786b431478f43855f55e03506b">operator = </a>(<span class="keyword">const</span> <span class="keywordtype">string</span>&amp; obj) {</div><div class="line"><a name="l00211"></a><span class="lineno">  211</span>&#160;         <span class="keywordflow">if</span> (<span class="keyword">this</span> != &amp;obj) {</div><div class="line"><a name="l00212"></a><span class="lineno">  212</span>&#160;           release_data_if_needed();</div><div class="line"><a name="l00213"></a><span class="lineno">  213</span>&#160;           data = obj.data;</div><div class="line"><a name="l00214"></a><span class="lineno">  214</span>&#160;           size = obj.size;</div><div class="line"><a name="l00215"></a><span class="lineno">  215</span>&#160;           own_memory = obj.own_memory;</div><div class="line"><a name="l00216"></a><span class="lineno">  216</span>&#160;           refcount = obj.refcount;</div><div class="line"><a name="l00217"></a><span class="lineno">  217</span>&#160;           <span class="keywordflow">if</span> (refcount != <span class="keyword">nullptr</span>) (*refcount)++;</div><div class="line"><a name="l00218"></a><span class="lineno">  218</span>&#160;         }</div><div class="line"><a name="l00219"></a><span class="lineno">  219</span>&#160;         <span class="keywordflow">return</span> *<span class="keyword">this</span>;</div><div class="line"><a name="l00220"></a><span class="lineno">  220</span>&#160;       }</div><div class="line"><a name="l00221"></a><span class="lineno">  221</span>&#160;</div><div class="line"><a name="l00228"></a><span class="lineno"><a class="line" href="classeosio_1_1string.html#a777848d8d3da75f0ba1b53b730e68da7">  228</a></span>&#160;       <span class="keywordtype">string</span>&amp; <a class="code" href="classeosio_1_1string.html#ade94c8786b431478f43855f55e03506b">operator = </a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* cstr) {</div><div class="line"><a name="l00229"></a><span class="lineno">  229</span>&#160;           release_data_if_needed();</div><div class="line"><a name="l00230"></a><span class="lineno">  230</span>&#160;           size = <a class="code" href="namespaceeosio.html#aae68db66d8f7985f4eb21e2d80432b28">cstrlen</a>(cstr) + 1;</div><div class="line"><a name="l00231"></a><span class="lineno">  231</span>&#160;           data = (<span class="keywordtype">char</span> *)<a class="code" href="group__memorycppapi.html#gac4387e5dad9585f885c0c0bf8d353739">malloc</a>(size * <span class="keyword">sizeof</span>(<span class="keywordtype">char</span>));</div><div class="line"><a name="l00232"></a><span class="lineno">  232</span>&#160;           <a class="code" href="group__memorycapi.html#ga59ed1449718a3c27f7622cb3efb845af">memcpy</a>(data, cstr, size * <span class="keyword">sizeof</span>(<span class="keywordtype">char</span>));</div><div class="line"><a name="l00233"></a><span class="lineno">  233</span>&#160;           own_memory = <span class="keyword">true</span>;</div><div class="line"><a name="l00234"></a><span class="lineno">  234</span>&#160;           refcount = (<a class="code" href="group__types.html#ga06896e8c53f721507066c079052171f8">uint32_t</a>*)<a class="code" href="group__memorycppapi.html#gac4387e5dad9585f885c0c0bf8d353739">malloc</a>(<span class="keyword">sizeof</span>(<a class="code" href="group__types.html#ga06896e8c53f721507066c079052171f8">uint32_t</a>));</div><div class="line"><a name="l00235"></a><span class="lineno">  235</span>&#160;           *refcount = 1;</div><div class="line"><a name="l00236"></a><span class="lineno">  236</span>&#160;           <span class="keywordflow">return</span> *<span class="keyword">this</span>;</div><div class="line"><a name="l00237"></a><span class="lineno">  237</span>&#160;       }</div><div class="line"><a name="l00238"></a><span class="lineno">  238</span>&#160;</div><div class="line"><a name="l00239"></a><span class="lineno"><a class="line" href="classeosio_1_1string.html#af5863518aeae1ff02f46c1c166786461">  239</a></span>&#160;       <span class="keywordtype">string</span>&amp; <a class="code" href="classeosio_1_1string.html#af5863518aeae1ff02f46c1c166786461">operator += </a>(<span class="keyword">const</span> <span class="keywordtype">string</span>&amp; str){</div><div class="line"><a name="l00240"></a><span class="lineno">  240</span>&#160;         <a class="code" href="group__systemcapi.html#gae2a6ebaf48fe7c69f847ae18f109d09a">assert</a>((size + str.size &gt; size) &amp;&amp; (size + str.size &gt; str.size), <span class="stringliteral">&quot;overflow&quot;</span>);</div><div class="line"><a name="l00241"></a><span class="lineno">  241</span>&#160;</div><div class="line"><a name="l00242"></a><span class="lineno">  242</span>&#160;         <span class="keywordtype">char</span>* new_data;</div><div class="line"><a name="l00243"></a><span class="lineno">  243</span>&#160;         <span class="keywordtype">size_t</span> new_size;</div><div class="line"><a name="l00244"></a><span class="lineno">  244</span>&#160;         <span class="keywordflow">if</span> (size &gt; 0 &amp;&amp; *(data + size - 1) == <span class="charliteral">&#39;\0&#39;</span>) {</div><div class="line"><a name="l00245"></a><span class="lineno">  245</span>&#160;           <span class="comment">// Null terminated string, remove the \0 when concatenates</span></div><div class="line"><a name="l00246"></a><span class="lineno">  246</span>&#160;           new_size = size - 1 + str.size;</div><div class="line"><a name="l00247"></a><span class="lineno">  247</span>&#160;           new_data = (<span class="keywordtype">char</span> *)<a class="code" href="group__memorycppapi.html#gac4387e5dad9585f885c0c0bf8d353739">malloc</a>(new_size * <span class="keyword">sizeof</span>(<span class="keywordtype">char</span>));</div><div class="line"><a name="l00248"></a><span class="lineno">  248</span>&#160;           <a class="code" href="group__memorycapi.html#ga59ed1449718a3c27f7622cb3efb845af">memcpy</a>(new_data, data, (size - 1) * <span class="keyword">sizeof</span>(<span class="keywordtype">char</span>));</div><div class="line"><a name="l00249"></a><span class="lineno">  249</span>&#160;           <a class="code" href="group__memorycapi.html#ga59ed1449718a3c27f7622cb3efb845af">memcpy</a>(new_data + size - 1, str.data, str.size * <span class="keyword">sizeof</span>(<span class="keywordtype">char</span>));</div><div class="line"><a name="l00250"></a><span class="lineno">  250</span>&#160;         } <span class="keywordflow">else</span> {</div><div class="line"><a name="l00251"></a><span class="lineno">  251</span>&#160;           new_size = size + str.size;</div><div class="line"><a name="l00252"></a><span class="lineno">  252</span>&#160;           new_data = (<span class="keywordtype">char</span> *)<a class="code" href="group__memorycppapi.html#gac4387e5dad9585f885c0c0bf8d353739">malloc</a>(new_size * <span class="keyword">sizeof</span>(<span class="keywordtype">char</span>));</div><div class="line"><a name="l00253"></a><span class="lineno">  253</span>&#160;           <a class="code" href="group__memorycapi.html#ga59ed1449718a3c27f7622cb3efb845af">memcpy</a>(new_data, data, size * <span class="keyword">sizeof</span>(<span class="keywordtype">char</span>));</div><div class="line"><a name="l00254"></a><span class="lineno">  254</span>&#160;           <a class="code" href="group__memorycapi.html#ga59ed1449718a3c27f7622cb3efb845af">memcpy</a>(new_data + size, str.data, str.size * <span class="keyword">sizeof</span>(<span class="keywordtype">char</span>));</div><div class="line"><a name="l00255"></a><span class="lineno">  255</span>&#160;         }</div><div class="line"><a name="l00256"></a><span class="lineno">  256</span>&#160;</div><div class="line"><a name="l00257"></a><span class="lineno">  257</span>&#160;         <span class="comment">// Release old data</span></div><div class="line"><a name="l00258"></a><span class="lineno">  258</span>&#160;         release_data_if_needed();</div><div class="line"><a name="l00259"></a><span class="lineno">  259</span>&#160;         <span class="comment">// Assign new data</span></div><div class="line"><a name="l00260"></a><span class="lineno">  260</span>&#160;         data = new_data;</div><div class="line"><a name="l00261"></a><span class="lineno">  261</span>&#160;</div><div class="line"><a name="l00262"></a><span class="lineno">  262</span>&#160;         size = new_size;</div><div class="line"><a name="l00263"></a><span class="lineno">  263</span>&#160;         own_memory = <span class="keyword">true</span>;</div><div class="line"><a name="l00264"></a><span class="lineno">  264</span>&#160;         refcount = (<a class="code" href="group__types.html#ga06896e8c53f721507066c079052171f8">uint32_t</a>*)<a class="code" href="group__memorycppapi.html#gac4387e5dad9585f885c0c0bf8d353739">malloc</a>(<span class="keyword">sizeof</span>(<a class="code" href="group__types.html#ga06896e8c53f721507066c079052171f8">uint32_t</a>));</div><div class="line"><a name="l00265"></a><span class="lineno">  265</span>&#160;         *refcount = 1;</div><div class="line"><a name="l00266"></a><span class="lineno">  266</span>&#160;</div><div class="line"><a name="l00267"></a><span class="lineno">  267</span>&#160;         <span class="keywordflow">return</span> *<span class="keyword">this</span>;</div><div class="line"><a name="l00268"></a><span class="lineno">  268</span>&#160;       }</div><div class="line"><a name="l00269"></a><span class="lineno">  269</span>&#160;</div><div class="line"><a name="l00270"></a><span class="lineno">  270</span>&#160;       <span class="comment">// Compare two strings</span></div><div class="line"><a name="l00271"></a><span class="lineno">  271</span>&#160;       <span class="comment">// Return an integral value indicating the relationship between strings</span></div><div class="line"><a name="l00272"></a><span class="lineno">  272</span>&#160;       <span class="comment">//   &gt;0 if the first string is greater than the second string</span></div><div class="line"><a name="l00273"></a><span class="lineno">  273</span>&#160;       <span class="comment">//   0 if both strings are equal</span></div><div class="line"><a name="l00274"></a><span class="lineno">  274</span>&#160;       <span class="comment">//   &lt;0 if the first string is smaller than the second string</span></div><div class="line"><a name="l00275"></a><span class="lineno">  275</span>&#160;       <span class="comment">// The return value also represents the difference between the first character that doesn&#39;t match of the two strings</span></div><div class="line"><a name="l00276"></a><span class="lineno"><a class="line" href="classeosio_1_1string.html#a55fb26a6d5c77e1476bb3f88b099753e">  276</a></span>&#160;       <a class="code" href="group__types.html#ga0d2e949ab6a1bb62f1b295cc79bc1f60">int32_t</a> <a class="code" href="classeosio_1_1string.html#a55fb26a6d5c77e1476bb3f88b099753e">compare</a>(<span class="keyword">const</span> <span class="keywordtype">string</span>&amp; str)<span class="keyword"> const </span>{</div><div class="line"><a name="l00277"></a><span class="lineno">  277</span>&#160;         <a class="code" href="group__types.html#ga0d2e949ab6a1bb62f1b295cc79bc1f60">int32_t</a> result;</div><div class="line"><a name="l00278"></a><span class="lineno">  278</span>&#160;         <span class="keywordflow">if</span> (size == str.size) {</div><div class="line"><a name="l00279"></a><span class="lineno">  279</span>&#160;           result = <a class="code" href="group__memorycapi.html#ga174f86fdde222a278e5524a8aea63da9">memcmp</a>(data, str.data, size);</div><div class="line"><a name="l00280"></a><span class="lineno">  280</span>&#160;         } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (size &lt; str.size) {</div><div class="line"><a name="l00281"></a><span class="lineno">  281</span>&#160;           result = <a class="code" href="group__memorycapi.html#ga174f86fdde222a278e5524a8aea63da9">memcmp</a>(data, str.data, size);</div><div class="line"><a name="l00282"></a><span class="lineno">  282</span>&#160;           <span class="keywordflow">if</span> (result == 0) {</div><div class="line"><a name="l00283"></a><span class="lineno">  283</span>&#160;             <span class="comment">// String is equal up to size of the shorter string, return the difference in byte of the next character</span></div><div class="line"><a name="l00284"></a><span class="lineno">  284</span>&#160;             result = 0 - (<span class="keywordtype">unsigned</span> char)str.data[size];</div><div class="line"><a name="l00285"></a><span class="lineno">  285</span>&#160;           }</div><div class="line"><a name="l00286"></a><span class="lineno">  286</span>&#160;         } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (size &gt; str.size) {</div><div class="line"><a name="l00287"></a><span class="lineno">  287</span>&#160;           result = <a class="code" href="group__memorycapi.html#ga174f86fdde222a278e5524a8aea63da9">memcmp</a>(data, str.data, str.size);</div><div class="line"><a name="l00288"></a><span class="lineno">  288</span>&#160;           <span class="keywordflow">if</span> (result == 0) {</div><div class="line"><a name="l00289"></a><span class="lineno">  289</span>&#160;             <span class="comment">// String is equal up to size of the shorter string, return the difference in byte of the next character</span></div><div class="line"><a name="l00290"></a><span class="lineno">  290</span>&#160;             result = (<span class="keywordtype">unsigned</span> char)data[str.size];</div><div class="line"><a name="l00291"></a><span class="lineno">  291</span>&#160;           }</div><div class="line"><a name="l00292"></a><span class="lineno">  292</span>&#160;         }</div><div class="line"><a name="l00293"></a><span class="lineno">  293</span>&#160;         <span class="keywordflow">return</span> result;</div><div class="line"><a name="l00294"></a><span class="lineno">  294</span>&#160;       }</div><div class="line"><a name="l00295"></a><span class="lineno">  295</span>&#160;</div><div class="line"><a name="l00296"></a><span class="lineno"><a class="line" href="classeosio_1_1string.html#a91fd184cf0f9333c217130cebd4d7876">  296</a></span>&#160;       <span class="keyword">friend</span> <span class="keywordtype">bool</span> <a class="code" href="classeosio_1_1string.html#a91fd184cf0f9333c217130cebd4d7876">operator &lt; </a>(<span class="keyword">const</span> <span class="keywordtype">string</span>&amp; lhs, <span class="keyword">const</span> <span class="keywordtype">string</span>&amp; rhs) {</div><div class="line"><a name="l00297"></a><span class="lineno">  297</span>&#160;         <span class="keywordflow">return</span> lhs.<a class="code" href="classeosio_1_1string.html#a55fb26a6d5c77e1476bb3f88b099753e">compare</a>(rhs) &lt; 0;</div><div class="line"><a name="l00298"></a><span class="lineno">  298</span>&#160;       }</div><div class="line"><a name="l00299"></a><span class="lineno">  299</span>&#160;</div><div class="line"><a name="l00300"></a><span class="lineno"><a class="line" href="classeosio_1_1string.html#abf763aa94a8644b190f43d6b026893a2">  300</a></span>&#160;       <span class="keyword">friend</span> <span class="keywordtype">bool</span> <a class="code" href="classeosio_1_1string.html#abf763aa94a8644b190f43d6b026893a2">operator &gt; </a>(<span class="keyword">const</span> <span class="keywordtype">string</span>&amp; lhs, <span class="keyword">const</span> <span class="keywordtype">string</span>&amp; rhs) {</div><div class="line"><a name="l00301"></a><span class="lineno">  301</span>&#160;         <span class="keywordflow">return</span> lhs.<a class="code" href="classeosio_1_1string.html#a55fb26a6d5c77e1476bb3f88b099753e">compare</a>(rhs) &gt; 0;</div><div class="line"><a name="l00302"></a><span class="lineno">  302</span>&#160;       }</div><div class="line"><a name="l00303"></a><span class="lineno">  303</span>&#160;</div><div class="line"><a name="l00304"></a><span class="lineno"><a class="line" href="classeosio_1_1string.html#a747feeacef8c26d89dafe7a9e32e2439">  304</a></span>&#160;       <span class="keyword">friend</span> <span class="keywordtype">bool</span> <a class="code" href="classeosio_1_1string.html#a747feeacef8c26d89dafe7a9e32e2439">operator == </a>(<span class="keyword">const</span> <span class="keywordtype">string</span>&amp; lhs, <span class="keyword">const</span> <span class="keywordtype">string</span>&amp; rhs) {</div><div class="line"><a name="l00305"></a><span class="lineno">  305</span>&#160;         <span class="keywordflow">return</span> lhs.<a class="code" href="classeosio_1_1string.html#a55fb26a6d5c77e1476bb3f88b099753e">compare</a>(rhs) == 0;</div><div class="line"><a name="l00306"></a><span class="lineno">  306</span>&#160;       }</div><div class="line"><a name="l00307"></a><span class="lineno">  307</span>&#160;</div><div class="line"><a name="l00308"></a><span class="lineno"><a class="line" href="classeosio_1_1string.html#ab8b27a889dc5ffef4a9cc7a1d1905b9c">  308</a></span>&#160;       <span class="keyword">friend</span> <span class="keywordtype">bool</span> <a class="code" href="classeosio_1_1string.html#ab8b27a889dc5ffef4a9cc7a1d1905b9c">operator != </a>(<span class="keyword">const</span> <span class="keywordtype">string</span>&amp; lhs, <span class="keyword">const</span> <span class="keywordtype">string</span>&amp; rhs) {</div><div class="line"><a name="l00309"></a><span class="lineno">  309</span>&#160;         <span class="keywordflow">return</span> lhs.<a class="code" href="classeosio_1_1string.html#a55fb26a6d5c77e1476bb3f88b099753e">compare</a>(rhs) != 0;</div><div class="line"><a name="l00310"></a><span class="lineno">  310</span>&#160;       }</div><div class="line"><a name="l00311"></a><span class="lineno">  311</span>&#160;</div><div class="line"><a name="l00312"></a><span class="lineno"><a class="line" href="classeosio_1_1string.html#a68ca7a7a35654ab6f2a2683b7d329442">  312</a></span>&#160;       <span class="keyword">friend</span> <span class="keywordtype">string</span> <a class="code" href="classeosio_1_1string.html#a68ca7a7a35654ab6f2a2683b7d329442">operator + </a>(<span class="keywordtype">string</span> lhs, <span class="keyword">const</span> <span class="keywordtype">string</span>&amp; rhs) {</div><div class="line"><a name="l00313"></a><span class="lineno">  313</span>&#160;         <span class="keywordflow">return</span> lhs += rhs;</div><div class="line"><a name="l00314"></a><span class="lineno">  314</span>&#160;       }</div><div class="line"><a name="l00315"></a><span class="lineno">  315</span>&#160;</div><div class="line"><a name="l00316"></a><span class="lineno">  316</span>&#160;       <span class="keyword">template</span>&lt;<span class="keyword">typename</span> DataStream&gt;</div><div class="line"><a name="l00317"></a><span class="lineno"><a class="line" href="classeosio_1_1string.html#ae9ee512fb742469af935b1f30d2dad4d">  317</a></span>&#160;       <span class="keyword">friend</span> DataStream&amp; <a class="code" href="classeosio_1_1string.html#ae9ee512fb742469af935b1f30d2dad4d">operator &lt;&lt; </a>( DataStream&amp; ds, <span class="keyword">const</span> <span class="keywordtype">string</span>&amp; t ){</div><div class="line"><a name="l00318"></a><span class="lineno">  318</span>&#160;          ds &lt;&lt; <a class="code" href="structunsigned__int.html">unsigned_int</a>( t.<a class="code" href="classeosio_1_1string.html#a7bc7a677ca79b2b3be0091e2d035f355">get_size</a>() );</div><div class="line"><a name="l00319"></a><span class="lineno">  319</span>&#160;          <span class="keywordflow">if</span>( t.<a class="code" href="classeosio_1_1string.html#a7bc7a677ca79b2b3be0091e2d035f355">get_size</a>() ) ds.write( t.<a class="code" href="classeosio_1_1string.html#ab969d69b5af645bc30e2d4a602cb016e">get_data</a>(), t.<a class="code" href="classeosio_1_1string.html#a7bc7a677ca79b2b3be0091e2d035f355">get_size</a>() );</div><div class="line"><a name="l00320"></a><span class="lineno">  320</span>&#160;          <span class="keywordflow">return</span> ds;</div><div class="line"><a name="l00321"></a><span class="lineno">  321</span>&#160;       }</div><div class="line"><a name="l00322"></a><span class="lineno">  322</span>&#160;       <span class="keyword">template</span>&lt;<span class="keyword">typename</span> DataStream&gt;</div><div class="line"><a name="l00323"></a><span class="lineno"><a class="line" href="classeosio_1_1string.html#a1376fac480768d6115b389fd18de769f">  323</a></span>&#160;       <span class="keyword">friend</span> DataStream&amp; <a class="code" href="classeosio_1_1string.html#a1376fac480768d6115b389fd18de769f">operator &gt;&gt; </a>( DataStream&amp; ds, <span class="keywordtype">string</span>&amp; t ){</div><div class="line"><a name="l00324"></a><span class="lineno">  324</span>&#160;          <a class="code" href="structunsigned__int.html">unsigned_int</a> size;</div><div class="line"><a name="l00325"></a><span class="lineno">  325</span>&#160;          ds &gt;&gt; size;</div><div class="line"><a name="l00326"></a><span class="lineno">  326</span>&#160;          t.<a class="code" href="classeosio_1_1string.html#a8d395e277ce5848b5a642b0d40babe9b">resize</a>( size );</div><div class="line"><a name="l00327"></a><span class="lineno">  327</span>&#160;          <span class="keywordflow">if</span>( size.value )</div><div class="line"><a name="l00328"></a><span class="lineno">  328</span>&#160;             ds.read( t.<a class="code" href="classeosio_1_1string.html#ab969d69b5af645bc30e2d4a602cb016e">get_data</a>(), size.value );</div><div class="line"><a name="l00329"></a><span class="lineno">  329</span>&#160;          <span class="keywordflow">return</span> ds;</div><div class="line"><a name="l00330"></a><span class="lineno">  330</span>&#160;       }</div><div class="line"><a name="l00331"></a><span class="lineno">  331</span>&#160;</div><div class="line"><a name="l00332"></a><span class="lineno">  332</span>&#160;</div><div class="line"><a name="l00333"></a><span class="lineno"><a class="line" href="classeosio_1_1string.html#afe503d29eaae256ea611fbe5e1525b7e">  333</a></span>&#160;       <span class="keywordtype">void</span> <a class="code" href="classeosio_1_1string.html#afe503d29eaae256ea611fbe5e1525b7e">print</a>()<span class="keyword"> const </span>{</div><div class="line"><a name="l00334"></a><span class="lineno">  334</span>&#160;         <span class="keywordflow">if</span> (size &gt; 0 &amp;&amp; *(data + size - 1) == <span class="charliteral">&#39;\0&#39;</span>) {</div><div class="line"><a name="l00335"></a><span class="lineno">  335</span>&#160;           <span class="comment">// Null terminated string</span></div><div class="line"><a name="l00336"></a><span class="lineno">  336</span>&#160;           <a class="code" href="group__consolecapi.html#gaa99be0cc1b9e5cbbc2b12a43537e7ed3">prints</a>(data);</div><div class="line"><a name="l00337"></a><span class="lineno">  337</span>&#160;         } <span class="keywordflow">else</span> {</div><div class="line"><a name="l00338"></a><span class="lineno">  338</span>&#160;           <span class="comment">// Non null terminated string</span></div><div class="line"><a name="l00339"></a><span class="lineno">  339</span>&#160;           <span class="comment">// We need to specify the size of string so it knows where to stop</span></div><div class="line"><a name="l00340"></a><span class="lineno">  340</span>&#160;           <a class="code" href="group__consolecapi.html#ga63ff8a7c0b046968ab2864df7284c910">prints_l</a>(data, size);</div><div class="line"><a name="l00341"></a><span class="lineno">  341</span>&#160;         }</div><div class="line"><a name="l00342"></a><span class="lineno">  342</span>&#160;      }</div><div class="line"><a name="l00343"></a><span class="lineno">  343</span>&#160;  }; </div><div class="line"><a name="l00344"></a><span class="lineno">  344</span>&#160;</div><div class="line"><a name="l00345"></a><span class="lineno">  345</span>&#160;}</div><div class="ttc" id="classeosio_1_1string_html_aade33fbfd95a6faebea6da1f1486cba7"><div class="ttname"><a href="classeosio_1_1string.html#aade33fbfd95a6faebea6da1f1486cba7">eosio::string::string</a></div><div class="ttdeci">string()</div><div class="ttdef"><b>Definition:</b> string.hpp:45</div></div>
<div class="ttc" id="classeosio_1_1string_html_a835d2c31ac35dbec36ab6d219ea87c8a"><div class="ttname"><a href="classeosio_1_1string.html#a835d2c31ac35dbec36ab6d219ea87c8a">eosio::string::operator[]</a></div><div class="ttdeci">char operator[](const size_t index)</div><div class="ttdef"><b>Definition:</b> string.hpp:204</div></div>
<div class="ttc" id="namespaceeosio_html"><div class="ttname"><a href="namespaceeosio.html">eosio</a></div><div class="ttdoc">Used to forward declare raw functions. </div><div class="ttdef"><b>Definition:</b> account.hpp:12</div></div>
<div class="ttc" id="classeosio_1_1string_html_ab969d69b5af645bc30e2d4a602cb016e"><div class="ttname"><a href="classeosio_1_1string.html#ab969d69b5af645bc30e2d4a602cb016e">eosio::string::get_data</a></div><div class="ttdeci">const char * get_data() const</div><div class="ttdef"><b>Definition:</b> string.hpp:135</div></div>
<div class="ttc" id="classeosio_1_1string_html_a32d0a50d44d2548303037d1eecedd077"><div class="ttname"><a href="classeosio_1_1string.html#a32d0a50d44d2548303037d1eecedd077">eosio::string::string</a></div><div class="ttdeci">string(const string &amp;obj)</div><div class="ttdef"><b>Definition:</b> string.hpp:76</div></div>
<div class="ttc" id="classeosio_1_1string_html_aac90a49eab4c1c047f40bf7e34fb46c9"><div class="ttname"><a href="classeosio_1_1string.html#aac90a49eab4c1c047f40bf7e34fb46c9">eosio::string::clear</a></div><div class="ttdeci">void clear()</div><div class="ttdef"><b>Definition:</b> string.hpp:184</div></div>
<div class="ttc" id="classeosio_1_1string_html_ab8b27a889dc5ffef4a9cc7a1d1905b9c"><div class="ttname"><a href="classeosio_1_1string.html#ab8b27a889dc5ffef4a9cc7a1d1905b9c">eosio::string::operator!=</a></div><div class="ttdeci">friend bool operator!=(const string &amp;lhs, const string &amp;rhs)</div><div class="ttdef"><b>Definition:</b> string.hpp:308</div></div>
<div class="ttc" id="group__systemcapi_html_gae2a6ebaf48fe7c69f847ae18f109d09a"><div class="ttname"><a href="group__systemcapi.html#gae2a6ebaf48fe7c69f847ae18f109d09a">assert</a></div><div class="ttdeci">void assert(uint32_t test, const char *cstr)</div><div class="ttdoc">Aborts processing of this action and unwinds all pending changes. </div></div>
<div class="ttc" id="print_8hpp_html"><div class="ttname"><a href="print_8hpp.html">print.hpp</a></div></div>
<div class="ttc" id="classeosio_1_1string_html_ade94c8786b431478f43855f55e03506b"><div class="ttname"><a href="classeosio_1_1string.html#ade94c8786b431478f43855f55e03506b">eosio::string::operator=</a></div><div class="ttdeci">string &amp; operator=(const string &amp;obj)</div><div class="ttdef"><b>Definition:</b> string.hpp:210</div></div>
<div class="ttc" id="classeosio_1_1string_html_a1376fac480768d6115b389fd18de769f"><div class="ttname"><a href="classeosio_1_1string.html#a1376fac480768d6115b389fd18de769f">eosio::string::operator&gt;&gt;</a></div><div class="ttdeci">friend DataStream &amp; operator&gt;&gt;(DataStream &amp;ds, string &amp;t)</div><div class="ttdef"><b>Definition:</b> string.hpp:323</div></div>
<div class="ttc" id="group__memorycapi_html_ga174f86fdde222a278e5524a8aea63da9"><div class="ttname"><a href="group__memorycapi.html#ga174f86fdde222a278e5524a8aea63da9">memcmp</a></div><div class="ttdeci">int32_t memcmp(void *ptr1, const void *ptr2, uint32_t num)</div><div class="ttdoc">Copy a block of memory from source to destination. </div></div>
<div class="ttc" id="string_8h_html"><div class="ttname"><a href="string_8h.html">string.h</a></div></div>
<div class="ttc" id="classeosio_1_1string_html_ab18d966a1121e47005d02eb54c980144"><div class="ttname"><a href="classeosio_1_1string.html#ab18d966a1121e47005d02eb54c980144">eosio::string::~string</a></div><div class="ttdeci">~string()</div><div class="ttdef"><b>Definition:</b> string.hpp:102</div></div>
<div class="ttc" id="classeosio_1_1string_html_abf763aa94a8644b190f43d6b026893a2"><div class="ttname"><a href="classeosio_1_1string.html#abf763aa94a8644b190f43d6b026893a2">eosio::string::operator&gt;</a></div><div class="ttdeci">friend bool operator&gt;(const string &amp;lhs, const string &amp;rhs)</div><div class="ttdef"><b>Definition:</b> string.hpp:300</div></div>
<div class="ttc" id="classeosio_1_1string_html_aa5268fb5a75d39cb43a853f40d20925c"><div class="ttname"><a href="classeosio_1_1string.html#aa5268fb5a75d39cb43a853f40d20925c">eosio::string::get_data</a></div><div class="ttdeci">char * get_data()</div><div class="ttdef"><b>Definition:</b> string.hpp:138</div></div>
<div class="ttc" id="classeosio_1_1string_html_acc5a44fa32bd5c717cba547333461d39"><div class="ttname"><a href="classeosio_1_1string.html#acc5a44fa32bd5c717cba547333461d39">eosio::string::substr</a></div><div class="ttdeci">string substr(size_t offset, size_t substr_size, bool copy)</div><div class="ttdef"><b>Definition:</b> string.hpp:199</div></div>
<div class="ttc" id="classeosio_1_1string_html_a808f9f108bfcd8acd062483e40f46080"><div class="ttname"><a href="classeosio_1_1string.html#a808f9f108bfcd8acd062483e40f46080">eosio::string::get_refcount</a></div><div class="ttdeci">const uint32_t get_refcount() const</div><div class="ttdef"><b>Definition:</b> string.hpp:148</div></div>
<div class="ttc" id="classeosio_1_1string_html_a826441441ab6ad0d7b68240714658534"><div class="ttname"><a href="classeosio_1_1string.html#a826441441ab6ad0d7b68240714658534">eosio::string::string</a></div><div class="ttdeci">string(const char *cstr)</div><div class="ttdoc">Constructor for string literal Non-null terminated string need to be passed here, Otherwise it will h...</div><div class="ttdef"><b>Definition:</b> string.hpp:92</div></div>
<div class="ttc" id="classeosio_1_1string_html_a747feeacef8c26d89dafe7a9e32e2439"><div class="ttname"><a href="classeosio_1_1string.html#a747feeacef8c26d89dafe7a9e32e2439">eosio::string::operator==</a></div><div class="ttdeci">friend bool operator==(const string &amp;lhs, const string &amp;rhs)</div><div class="ttdef"><b>Definition:</b> string.hpp:304</div></div>
<div class="ttc" id="classeosio_1_1string_html_add233f23d0dbcd7ccd96de9d1d2ed2d9"><div class="ttname"><a href="classeosio_1_1string.html#add233f23d0dbcd7ccd96de9d1d2ed2d9">eosio::string::string</a></div><div class="ttdeci">string(size_t s)</div><div class="ttdef"><b>Definition:</b> string.hpp:52</div></div>
<div class="ttc" id="types_8hpp_html"><div class="ttname"><a href="types_8hpp.html">types.hpp</a></div></div>
<div class="ttc" id="group__memorycppapi_html_gadc937e4380b5ab7212b4b603ccc516c5"><div class="ttname"><a href="group__memorycppapi.html#gadc937e4380b5ab7212b4b603ccc516c5">eosio::free</a></div><div class="ttdeci">void free(void *ptr)</div><div class="ttdoc">Free a block of memory. </div><div class="ttdef"><b>Definition:</b> memory.hpp:529</div></div>
<div class="ttc" id="group__memorycapi_html_ga59ed1449718a3c27f7622cb3efb845af"><div class="ttname"><a href="group__memorycapi.html#ga59ed1449718a3c27f7622cb3efb845af">memcpy</a></div><div class="ttdeci">void * memcpy(void *destination, const void *source, uint32_t num)</div><div class="ttdoc">Copy a block of memory from source to destination. </div></div>
<div class="ttc" id="classeosio_1_1string_html_afe503d29eaae256ea611fbe5e1525b7e"><div class="ttname"><a href="classeosio_1_1string.html#afe503d29eaae256ea611fbe5e1525b7e">eosio::string::print</a></div><div class="ttdeci">void print() const</div><div class="ttdef"><b>Definition:</b> string.hpp:333</div></div>
<div class="ttc" id="classeosio_1_1string_html_a91fd184cf0f9333c217130cebd4d7876"><div class="ttname"><a href="classeosio_1_1string.html#a91fd184cf0f9333c217130cebd4d7876">eosio::string::operator&lt;</a></div><div class="ttdeci">friend bool operator&lt;(const string &amp;lhs, const string &amp;rhs)</div><div class="ttdef"><b>Definition:</b> string.hpp:296</div></div>
<div class="ttc" id="group__consolecapi_html_ga63ff8a7c0b046968ab2864df7284c910"><div class="ttname"><a href="group__consolecapi.html#ga63ff8a7c0b046968ab2864df7284c910">prints_l</a></div><div class="ttdeci">void prints_l(const char *cstr, uint32_t len)</div><div class="ttdoc">Prints string. </div></div>
<div class="ttc" id="classeosio_1_1string_html_a813bb1e0b11250761b63d48e3bf387b5"><div class="ttname"><a href="classeosio_1_1string.html#a813bb1e0b11250761b63d48e3bf387b5">eosio::string::is_own_memory</a></div><div class="ttdeci">const bool is_own_memory() const</div><div class="ttdef"><b>Definition:</b> string.hpp:143</div></div>
<div class="ttc" id="group__consolecapi_html_gaa99be0cc1b9e5cbbc2b12a43537e7ed3"><div class="ttname"><a href="group__consolecapi.html#gaa99be0cc1b9e5cbbc2b12a43537e7ed3">prints</a></div><div class="ttdeci">void prints(const char *cstr)</div><div class="ttdoc">Prints string. </div></div>
<div class="ttc" id="structunsigned__int_html"><div class="ttname"><a href="structunsigned__int.html">unsigned_int</a></div><div class="ttdef"><b>Definition:</b> varint.hpp:14</div></div>
<div class="ttc" id="group__types_html_ga06896e8c53f721507066c079052171f8"><div class="ttname"><a href="group__types.html#ga06896e8c53f721507066c079052171f8">uint32_t</a></div><div class="ttdeci">unsigned long uint32_t</div><div class="ttdef"><b>Definition:</b> types.h:19</div></div>
<div class="ttc" id="classeosio_1_1string_html_a7bc7a677ca79b2b3be0091e2d035f355"><div class="ttname"><a href="classeosio_1_1string.html#a7bc7a677ca79b2b3be0091e2d035f355">eosio::string::get_size</a></div><div class="ttdeci">const size_t get_size() const</div><div class="ttdef"><b>Definition:</b> string.hpp:130</div></div>
<div class="ttc" id="classeosio_1_1string_html_a8d92d1d32e18406f45f6b3ee2279606c"><div class="ttname"><a href="classeosio_1_1string.html#a8d92d1d32e18406f45f6b3ee2279606c">eosio::string::string</a></div><div class="ttdeci">string(char *d, size_t s, bool copy)</div><div class="ttdef"><b>Definition:</b> string.hpp:71</div></div>
<div class="ttc" id="classeosio_1_1string_html"><div class="ttname"><a href="classeosio_1_1string.html">eosio::string</a></div><div class="ttdef"><b>Definition:</b> string.hpp:24</div></div>
<div class="ttc" id="namespaceeosio_html_aae68db66d8f7985f4eb21e2d80432b28"><div class="ttname"><a href="namespaceeosio.html#aae68db66d8f7985f4eb21e2d80432b28">eosio::cstrlen</a></div><div class="ttdeci">size_t cstrlen(const char *cstr)</div><div class="ttdoc">Count the length of null terminated string (excluding the null terminated symbol) Non-null terminated...</div><div class="ttdef"><b>Definition:</b> string.hpp:15</div></div>
<div class="ttc" id="group__types_html_ga0d2e949ab6a1bb62f1b295cc79bc1f60"><div class="ttname"><a href="group__types.html#ga0d2e949ab6a1bb62f1b295cc79bc1f60">int32_t</a></div><div class="ttdeci">long int32_t</div><div class="ttdef"><b>Definition:</b> types.h:25</div></div>
<div class="ttc" id="system_8h_html"><div class="ttname"><a href="system_8h.html">system.h</a></div></div>
<div class="ttc" id="classeosio_1_1string_html_aaed931c80e0dd8542e19b211f9dc7e73"><div class="ttname"><a href="classeosio_1_1string.html#aaed931c80e0dd8542e19b211f9dc7e73">eosio::string::assign</a></div><div class="ttdeci">string &amp; assign(char *d, size_t s, bool copy)</div><div class="ttdef"><b>Definition:</b> string.hpp:159</div></div>
<div class="ttc" id="classeosio_1_1string_html_ae9ee512fb742469af935b1f30d2dad4d"><div class="ttname"><a href="classeosio_1_1string.html#ae9ee512fb742469af935b1f30d2dad4d">eosio::string::operator&lt;&lt;</a></div><div class="ttdeci">friend DataStream &amp; operator&lt;&lt;(DataStream &amp;ds, const string &amp;t)</div><div class="ttdef"><b>Definition:</b> string.hpp:317</div></div>
<div class="ttc" id="classeosio_1_1string_html_a8d395e277ce5848b5a642b0d40babe9b"><div class="ttname"><a href="classeosio_1_1string.html#a8d395e277ce5848b5a642b0d40babe9b">eosio::string::resize</a></div><div class="ttdeci">void resize(size_t newsize)</div><div class="ttdef"><b>Definition:</b> string.hpp:106</div></div>
<div class="ttc" id="classeosio_1_1string_html_af5863518aeae1ff02f46c1c166786461"><div class="ttname"><a href="classeosio_1_1string.html#af5863518aeae1ff02f46c1c166786461">eosio::string::operator+=</a></div><div class="ttdeci">string &amp; operator+=(const string &amp;str)</div><div class="ttdef"><b>Definition:</b> string.hpp:239</div></div>
<div class="ttc" id="classeosio_1_1string_html_a68ca7a7a35654ab6f2a2683b7d329442"><div class="ttname"><a href="classeosio_1_1string.html#a68ca7a7a35654ab6f2a2683b7d329442">eosio::string::operator+</a></div><div class="ttdeci">friend string operator+(string lhs, const string &amp;rhs)</div><div class="ttdef"><b>Definition:</b> string.hpp:312</div></div>
<div class="ttc" id="memory_8hpp_html"><div class="ttname"><a href="memory_8hpp.html">memory.hpp</a></div></div>
<div class="ttc" id="group__memorycppapi_html_gac4387e5dad9585f885c0c0bf8d353739"><div class="ttname"><a href="group__memorycppapi.html#gac4387e5dad9585f885c0c0bf8d353739">eosio::malloc</a></div><div class="ttdeci">void * malloc(uint32_t size)</div><div class="ttdoc">Allocate a block of memory. </div><div class="ttdef"><b>Definition:</b> memory.hpp:494</div></div>
<div class="ttc" id="classeosio_1_1string_html_a55fb26a6d5c77e1476bb3f88b099753e"><div class="ttname"><a href="classeosio_1_1string.html#a55fb26a6d5c77e1476bb3f88b099753e">eosio::string::compare</a></div><div class="ttdeci">int32_t compare(const string &amp;str) const</div><div class="ttdef"><b>Definition:</b> string.hpp:276</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.13
</small></address>
</body>
</html>
